package com.falm.picturebackend.entity.convert;

import com.falm.picturebackend.entity.BO.FileRelationsBO;
import com.falm.picturebackend.entity.DO.FileRelationsDO;
import com.falm.picturebackend.entity.VO.FileRelationsVO;

import java.util.List;
import java.util.stream.Collectors;

/**
 * @author Administrator
 */
public class FileRelationsConvert {

    public static FileRelationsBO do2BO(FileRelationsDO fileRelationsDO) {
        if (fileRelationsDO == null) {
            return null;
        }
        FileRelationsBO fileRelationsBO = new FileRelationsBO();
        fileRelationsBO.setId(fileRelationsDO.getId());
        fileRelationsBO.setSourceFileUuid(fileRelationsDO.getSourceFileUuid());
        fileRelationsBO.setTargetFileUuid(fileRelationsDO.getTargetFileUuid());
        fileRelationsBO.setRelationType(fileRelationsDO.getRelationType());
        fileRelationsBO.setCreateTime(fileRelationsDO.getCreateTime());
        return fileRelationsBO;
    }

    public static FileRelationsDO bo2DO(FileRelationsBO fileRelationsBO) {
        if (fileRelationsBO == null) {
            return null;
        }
        FileRelationsDO fileRelationsDO = new FileRelationsDO();
        fileRelationsDO.setId(fileRelationsBO.getId());
        fileRelationsDO.setSourceFileUuid(fileRelationsBO.getSourceFileUuid());
        fileRelationsDO.setTargetFileUuid(fileRelationsBO.getTargetFileUuid());
        fileRelationsDO.setRelationType(fileRelationsBO.getRelationType());
        fileRelationsDO.setCreateTime(fileRelationsBO.getCreateTime());
        return fileRelationsDO;
    }

    public static FileRelationsVO bo2VO(FileRelationsBO fileRelationsBO) {
        if (fileRelationsBO == null) {
            return null;
        }
        FileRelationsVO fileRelationsVO = new FileRelationsVO();
        fileRelationsVO.setId(fileRelationsBO.getId());
        fileRelationsVO.setSourceFileUuid(fileRelationsBO.getSourceFileUuid());
        fileRelationsVO.setTargetFileUuid(fileRelationsBO.getTargetFileUuid());
        fileRelationsVO.setRelationType(fileRelationsBO.getRelationType());
        fileRelationsVO.setCreateTime(fileRelationsBO.getCreateTime());
        return fileRelationsVO;
    }

    public static List<FileRelationsBO> do2BOList(List<FileRelationsDO> fileRelationsDOList) {
        return fileRelationsDOList.stream().map(FileRelationsConvert::do2BO).collect(Collectors.toList());
    }
}